var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function s() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((s.prototype = i.prototype), new s()));
      };
    })(),
  SendEmailGoodsDialog = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.emailArr = []),
        (t.spaceTime = 0),
        t.btn_emailGoods_close.on(Laya.Event.CLICK, t, t.onDidClickCloseFn),
        t.tab_email_goods.on(
          Laya.Event.CLICK,
          t,
          t.onTabFirstFloorDidClickItem
        ),
        t.tab_email_shitou.on(
          Laya.Event.CLICK,
          t,
          t.onTabSecondFloorDidClickItem
        ),
        (t.list_email_goods.vScrollBarSkin = ""),
        (t.list_email_goods.selectEnable = !0),
        t.list_email_goods.on(Laya.Event.CLICK, t, t.onDidClickGoodsFn),
        (t.list_email_goods.scrollBar.changeHandler = new Handler(
          t,
          t.onLoadMoreSendGoodsData
        )),
        (t.list_email_shitou.vScrollBarSkin = ""),
        (t.list_email_shitou.selectEnable = !0),
        t.list_email_shitou.on(Laya.Event.CLICK, t, t.onDidClickGoodsFn),
        (t.list_email_shitou.scrollBar.changeHandler = new Handler(
          t,
          t.onLoadMoreShiTouData
        )),
        WebSocketService.addListener({
          caller: t,
          code: 1172,
          method: t.onLoadSendGoodsDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1177,
          method: t.onLoadSendGoodsDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1179,
          method: t.onLoadSendGoodsDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1180,
          method: t.onLoadSendGoodsDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1175,
          method: t.onLoadSendStoneDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1178,
          method: t.onLoadSendStoneDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1173,
          method: t.onLoadSendStoneDataFn,
        }),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showEmailGoodsView = function () {
        null == this.selectGoodsVC &&
          ((this.selectGoodsVC = new t()), (this.selectGoodsVC.zOrder = 1e3)),
          this.selectGoodsVC.popup(!0),
          (this.selectGoodsVC.tab_email_goods.selectedIndex = 0),
          WebSocketService.send({ c: 1172, d: { pageNum: 0 } }),
          this.selectGoodsVC.init();
      }),
      (t.prototype.init = function () {
        (this.list_email_goods.visible = !0),
          (this.list_email_shitou.visible = !1),
          (this.tab_email_shitou.visible = !1),
          (this.currentPage = 0),
          (this.emailArr = []);
      }),
      (t.prototype.onTabFirstFloorDidClickItem = function (e) {
        (this.list_email_goods.visible = !1),
          (this.list_email_shitou.visible = !1),
          (this.tab_email_shitou.visible = !1),
          (this.emailArr = []),
          "item0" == e.target.name
            ? (WebSocketService.send({ c: 1172, d: { pageNum: 0 } }),
              (this.list_email_goods.visible = !0),
              this.list_email_goods.scrollTo(0))
            : "item1" == e.target.name
            ? (WebSocketService.send({ c: 1177, d: { pageNum: 0 } }),
              (this.list_email_goods.visible = !0),
              this.list_email_goods.scrollTo(0))
            : "item2" == e.target.name
            ? ((this.tab_email_shitou.visible = !0),
              (this.list_email_shitou.visible = !0),
              WebSocketService.send({ c: 1178, d: { pageNum: 0 } }),
              (this.tab_email_shitou.selectedIndex = 0),
              this.list_email_shitou.scrollTo(0))
            : "item3" == e.target.name
            ? (WebSocketService.send({ c: 1179, d: { pageNum: 0 } }),
              (this.list_email_goods.visible = !0),
              this.list_email_goods.scrollTo(0))
            : "item4" == e.target.name &&
              (WebSocketService.send({ c: 1180, d: { pageNum: 0 } }),
              (this.list_email_goods.visible = !0),
              this.list_email_goods.scrollTo(0));
      }),
      (t.prototype.onTabSecondFloorDidClickItem = function (e) {
        "item0" == e.target.name
          ? WebSocketService.send({ c: 1178, d: { pageNum: 0 } })
          : "item1" == e.target.name
          ? WebSocketService.send({ c: 1173, d: { pageNum: 0 } })
          : "item2" == e.target.name &&
            WebSocketService.send({ c: 1175, d: { pageNum: 0 } }),
          (this.emailArr = []),
          this.list_email_shitou.scrollTo(0);
      }),
      (t.prototype.onLoadMoreSendGoodsData = function (e) {
        var t = e / this.list_email_goods.scrollBar.max,
          i = new Date(),
          s = !1;
        if (
          (i.getTime() - this.spaceTime >= 3e3 && (s = !0),
          1 == t && 0 == this.isloading && s)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            0 == this.tab_email_goods.selectedIndex
              ? WebSocketService.send({
                  c: 1172,
                  d: { pageNum: this.currentPage },
                })
              : 1 == this.tab_email_goods.selectedIndex
              ? WebSocketService.send({
                  c: 1177,
                  d: { pageNum: this.currentPage },
                })
              : 2 == this.tab_email_goods.selectedIndex ||
                (3 == this.tab_email_goods.selectedIndex
                  ? WebSocketService.send({
                      c: 1179,
                      d: { pageNum: this.currentPage },
                    })
                  : 4 == this.tab_email_goods.selectedIndex &&
                    WebSocketService.send({
                      c: 1180,
                      d: { pageNum: this.currentPage },
                    })),
            void (this.spaceTime = i.getTime())
          );
      }),
      (t.prototype.onLoadMoreShiTouData = function (e) {
        var t = e / this.list_email_shitou.scrollBar.max,
          i = new Date(),
          s = !1;
        if (
          (i.getTime() - this.spaceTime >= 3e3 && (s = !0),
          1 == t && 0 == this.isloading && s)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            0 == this.tab_email_shitou.selectedIndex
              ? WebSocketService.send({
                  c: 1178,
                  d: { pageNum: this.currentPage },
                })
              : 1 == this.tab_email_shitou.selectedIndex
              ? WebSocketService.send({
                  c: 1173,
                  d: { pageNum: this.currentPage },
                })
              : 2 == this.tab_email_shitou.selectedIndex &&
                WebSocketService.send({
                  c: 1175,
                  d: { pageNum: this.currentPage },
                }),
            void (this.spaceTime = i.getTime())
          );
      }),
      (t.prototype.onLoadSendGoodsDataFn = function (e) {
        if (0 == e.code) {
          if (this.currentPage >= 1) {
            if (0 == e.list.length) return void this.currentPage--;
            for (s = 0; s < e.list.length; s++) {
              var t = e.list[s];
              this.emailArr.push(t), (this.dataSource = []);
            }
          } else (this.emailArr = e.list), (this.dataSource = []);
          this.emailArr.length > 0 && (this.list_email_goods.visible = !0),
            (this.isloading = !1);
          var i;
          if (1172 == e.act_id)
            for (s = 0; s < this.emailArr.length; s++)
              (i = {
                items_name: {
                  text:
                    this.emailArr[s].name + " " + this.emailArr[s].num + "个",
                },
                items_star: { text: "" },
              }),
                this.dataSource.push(i);
          else if (1177 == e.act_id)
            for (s = 0; s < this.emailArr.length; s++)
              (i = {
                items_name: { text: this.emailArr[s].name },
                items_star: { text: "" },
                check: !1,
              }),
                this.dataSource.push(i);
          else if (1179 == e.act_id)
            for (s = 0; s < this.emailArr.length; s++)
              (i = {
                items_name: { text: this.emailArr[s].name },
                items_star: { text: "" },
              }),
                this.dataSource.push(i);
          else if (1180 == e.act_id)
            for (var s = 0; s < this.emailArr.length; s++)
              (i = {
                items_name: { text: this.emailArr[s].name },
                items_star: {
                  text: this.dealSuboardStar(this.emailArr[s].star),
                },
              }),
                this.dataSource.push(i);
          this.list_email_goods.dataSource = this.dataSource;
        }
      }),
      (t.prototype.dealSuboardStar = function (e) {
        var t = "";
        return e > 0 && (t = " (" + e + "星) "), t;
      }),
      (t.prototype.onLoadSendStoneDataFn = function (e) {
        if (0 == e.code) {
          if (this.currentPage >= 1) {
            if (0 == e.list.length) return void this.currentPage--;
            for (s = 0; s < e.list.length; s++) {
              var t = e.list[s];
              this.emailArr.push(t), (this.dataSource = []);
            }
          } else (this.emailArr = e.list), (this.dataSource = []);
          this.emailArr.length > 0 && (this.list_email_shitou.visible = !0),
            (this.isloading = !1);
          var i;
          if (1178 == e.act_id)
            for (s = 0; s < this.emailArr.length; s++)
              (i = {
                email_type_shitou: {
                  text:
                    s +
                    1 +
                    ". " +
                    this.emailArr[s].lvl +
                    "级 " +
                    this.emailArr[s].name,
                },
              }),
                this.dataSource.push(i);
          else if (1173 == e.act_id)
            for (s = 0; s < this.emailArr.length; s++)
              (i = { email_type_shitou: { text: this.emailArr[s].name } }),
                this.dataSource.push(i);
          else if (1175 == e.act_id)
            for (var s = 0; s < this.emailArr.length; s++)
              (i = {
                email_type_shitou: {
                  text:
                    this.emailArr[s].lvl +
                    "级 " +
                    this.emailArr[s].name +
                    " (" +
                    this.emailArr[s].num +
                    "魂元）",
                },
              }),
                this.dataSource.push(i);
          this.list_email_shitou.dataSource = this.dataSource;
        }
      }),
      (t.prototype.onDidClickCloseFn = function () {
        this.close();
      }),
      (t.prototype.onDidClickGoodsFn = function (e) {
        if ("" != e.target.name)
          if (2 == this.tab_email_goods.selectedIndex) {
            t = void 0;
            if ("item_button_shitou" == e.target.name) {
              1 == this.tab_email_shitou.selectedIndex
                ? (t = "3")
                : 0 == this.tab_email_shitou.selectedIndex
                ? (t = "31")
                : 2 == this.tab_email_shitou.selectedIndex && (t = "32");
              i = this.emailArr[this.list_email_shitou.selectedIndex];
              SendGoodsDetailDialog.showGoodsView(i, t);
            }
          } else if ("items_button_one" == e.target.name) {
            var t = void 0;
            0 == this.tab_email_goods.selectedIndex
              ? (t = "1")
              : 1 == this.tab_email_goods.selectedIndex
              ? (t = "2")
              : 3 == this.tab_email_goods.selectedIndex
              ? (t = "4")
              : 4 == this.tab_email_goods.selectedIndex && (t = "5");
            var i = this.emailArr[this.list_email_goods.selectedIndex];
            SendGoodsDetailDialog.showGoodsView(i, t);
          }
      }),
      (t.prototype.showItemView = function (e, t, i) {
        if (e.target instanceof Laya.CheckBox) {
          var s = i[t];
          e.target.selected
            ? this.list_email_shitou.setItem(t, {
                email_type_second: { text: s.email_type_second.text },
                isCheck: !0,
              })
            : this.list_email_shitou.setItem(t, {
                email_type_second: { text: s.email_type_second.text },
                isCheck: !1,
              });
        }
      }),
      (t.close = function () {
        null == this.selectGoodsVC &&
          (this.selectGoodsVC.close(), (this.selectGoodsVC = null));
      }),
      t
    );
  })(ui.EmailController.SendEmailGoodsDialogUI);
